import 'package:flutter/material.dart';

void main() => runApp(DialogApp());

class DialogApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: HomePage(),
    );
  }
}

class HomePage extends StatefulWidget {
  @override
  _HomePageState createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Dialog的使用'),
      ),
      body: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        children: [
          SimpleDialog(
            title: Text('对话框的使用'),
            children: [
              SimpleDialogOption(
                child: Text('选项1'),
                onPressed: () {
                  print('选项1');
                },
              ),
              SimpleDialogOption(
                child: Text('选项2'),
                onPressed: () {
                  print('选项2');
                },
              ),
              RaisedButton(
                child: Text('删除'),
                onPressed: () {
                  showDialog(
                      context: context,
                      builder: (BuildContext context) {
                        return AlertDialog(
                          title: Text('温馨提示'),
                          content: SingleChildScrollView(
                            child: ListBody(
                              children: [Text('是否删除'), Text('删除后不可恢复')],
                            ),
                          ),
                          actions: [
                            FlatButton(
                              child: Text('删除'),
                              onPressed: () {
                                Navigator.of(context).pop();
                              },
                            )
                          ],
                        );
                      });
                },
              )
            ],
          ),
        ],
      ),
    );
  }
}
